#include "LocalScene.h"
#include "Utils/LogUtil.h"
#include "LocalEntity.h"
#include "Utils/StringUtil.h"
#include "Game/Component/Model.h"
#include "Render/RenderState.h"
#include "Render/Imgui/imgui.h"
#include "Math/Random.h"


void LocalScene::OnInit()
{
	mCamera.SetSpeed(5.f);

	GeometryGenerator geometryGenerator;
	GeometryGenerator::MeshData sphereData = geometryGenerator.CreateSphere(2.f, 40, 40);
	// GeometryGenerator::MeshData sphereData = geometryGenerator.CreateGeosphere(2.f, 20);

	LocalEntity* entity = CreateEntity<LocalEntity>("sphere");
	entity->AddComponent<Model>(sphereData);
	entity->GetTransform().SetLocalPosition(glm::vec3(2.5f, 0.f, 0.f));
	entity->GetTransform().UpdateMatrices();

	LocalEntity* shEntity = CreateEntity<LocalEntity>("shSphere");
	shEntity->AddComponent<Model>(sphereData);
	shEntity->GetTransform().SetLocalPosition(glm::vec3(-2.5f, 0.f, 0.f));
	shEntity->GetTransform().UpdateMatrices();

#if 0
	std::vector<uint8> projection_spirv;

	projection_spirv.resize(kSH_PROJECTION_SPIRV_size);
	memcpy(&projection_spirv[0], &kSH_PROJECTION_SPIRV_data[0], kSH_PROJECTION_SPIRV_size);

	std::vector<uint8> add_spirv;

	add_spirv.resize(kSH_ADD_SPIRV_size);
	memcpy(&add_spirv[0], &kSH_ADD_SPIRV_data[0], kSH_ADD_SPIRV_size);

	FileUtil::SaveArrayToFile(projection_spirv, "E:\\Projects\\Backup\\Shader\\SHProjection.spv");
	FileUtil::SaveArrayToFile(add_spirv, "E:\\Projects\\Backup\\Shader\\SHAdd.spv");
#endif
}

void LocalScene::OnExit()
{

}

void LocalScene::OnTick(float deltaTime)
{

}

void LocalScene::OnImgui()
{
	GameScene::OnImgui();

	// ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);

	//ImGui::Begin("ComputeTexture");



	//ImGui::End();
}
